import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

Vue.config.productionTip = false;

// 重置标签样式
import './styles/reset.css';
import './styles/normalize.css';

// import './router/routers';

new Vue({
    router,
    store,
    render: (h) => h(App),
}).$mount("#main");

import { registerMicroApps, start, setDefaultMountApp, initGlobalState, runAfterFirstMounted } from "qiankun";

registerMicroApps(
    [
        {
            name: "appVue",
            entry: "//localhost:5556",
            container: "#container",
            props: { name: "appVue" },
            activeRule: "/appVue",
        },
        {
            name: "appVue1",
            entry: "//localhost:5557",
            container: "#container",
            props: { name: "appVue1" },
            activeRule: "/appVue1",
        },
    ],
    {
        beforeLoad: [
            (app) => {
                console.log(
                    "[LifeCycle] before load %c%s",
                    "color: green;",
                    app.name
                );
            },
        ],
        beforeMount: [
            (app) => {
                console.log(
                    "[LifeCycle] before mount %c%s",
                    "color: green;",
                    app.name
                );
            },
        ],
        afterUnmount: [
            (app) => {
                console.log(
                    "[LifeCycle] after unmount %c%s",
                    "color: green;",
                    app.name
                );
            },
        ],
    }
);

const { onGlobalStateChange, setGlobalState } = initGlobalState({
    user: 'qiankun',
});
  
onGlobalStateChange((value, prev) => console.log('[onGlobalStateChange - master]:', value, prev));
  
setGlobalState({
    ignore: 'master',
    user: {
      name: 'master',
    },
});

// setDefaultMountApp("/appVue1");
// 启动 qiankun
start();

runAfterFirstMounted(() => {
    console.log('[MainApp] first app mounted');
    
});


